package com.biz.primus.ms.payment.api;

import com.biz.primus.base.vo.LongIdVo;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.payment.vo.req.MerchantQueryVo;
import com.biz.primus.model.payment.vo.req.MerchantReqVo;
import com.biz.primus.model.payment.vo.resp.MerchantResVo;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.payment.service.MerchantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author defei
 * @date 2017/9/22
 */
@RestController
@RequestMapping("soa/merchantService")
@Api(description = "商户相关接口文档")
public class MerchantApiController extends BaseApiController {

    private final MerchantService merchantService;

    @Autowired
    public MerchantApiController(MerchantService merchantService) {
        assert merchantService != null;
        this.merchantService = merchantService;
    }

    @ApiOperation("创建商户信息")
    @PostMapping("create")
    MerchantResVo create(@RequestBody MerchantReqVo reqVo) {

        return merchantService.create(reqVo);
    }

    @ApiOperation("获取商户信息")
    @PostMapping("getMerchantInfo")
    MerchantResVo findOne(@RequestBody LongIdVo reqVo) {

        return merchantService.getMerchantInfo(reqVo.getId());
    }

    @ApiOperation("根据条件查询分页展示")
    @PostMapping("findAll")
    public SpringPageVO<MerchantResVo> findAll(@RequestBody MerchantQueryVo queryVo) {

        return merchantService.findAll(queryVo);
    }

    @ApiOperation("更新商户信息")
    @PostMapping("update")
    public MerchantResVo update(@RequestBody MerchantReqVo reqVo) {

        return merchantService.update(reqVo);
    }
}
